//获取当前时间的方法
export function getCurrentTime() {
  const now = new Date();
  const hours = now.getHours().toString().padStart(2, "0");
  const minutes = now.getMinutes().toString().padStart(2, "0");
  const seconds = now.getSeconds().toString().padStart(2, "0");
  const currentTime = `${hours}:${minutes}:${seconds}`;
  return currentTime;
}

// // 调用方法获取当前时间
// const currentTime = getCurrentTime();
// console.log(currentTime); // 输出当前时间



// 格式化时间的方法

export function formatTimestamp(timestamp) {
  const milliseconds = timestamp * 1000;
  const dateObject = new Date(milliseconds);
  const year = dateObject.getFullYear();
  const month = ("0" + (dateObject.getMonth() + 1)).slice(-2);
  const day = ("0" + dateObject.getDate()).slice(-2);
  const hours = ("0" + dateObject.getHours()).slice(-2);
  const minutes = ("0" + dateObject.getMinutes()).slice(-2);
  const seconds = ("0" + dateObject.getSeconds()).slice(-2);

  return `${hours}:${minutes}:${seconds}`;
  // return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

export function formatTimestamp2(timestamp) {
  const milliseconds = timestamp * 1000;
  const dateObject = new Date(milliseconds);
  const year = dateObject.getFullYear();
  const month = ("0" + (dateObject.getMonth() + 1)).slice(-2);
  const day = ("0" + dateObject.getDate()).slice(-2);
  const hours = ("0" + dateObject.getHours()).slice(-2);
  const minutes = ("0" + dateObject.getMinutes()).slice(-2);
  const seconds = ("0" + dateObject.getSeconds()).slice(-2);

  // return `${hours}:${minutes}:${seconds}`;
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

// 获取当天时间的方法
export function getCurrentData() {
  const currentDate = new Date();
  const yy = currentDate.getFullYear();
  const mm = currentDate.getMonth() + 1;
  const dd = currentDate.getDate();
  let startCurrentTime = `${yy}-${mm}-${dd} 00:00:00`;
  let endCurrentTime = `${yy}-${mm}-${dd} 23:59:59`;
  let currentTime = `${yy}-${mm}-${dd}`

  return { startCurrentTime, endCurrentTime  ,currentTime};
}



// 获取当天时间的方法 可以传递参数的版本

export function afterDatePicker(date) {
  console.log("返回的date", date);
  const currentDate = new Date(date);
  const yy = currentDate.getFullYear();
  const mm = currentDate.getMonth() + 1;
  const dd = currentDate.getDate();
  let startCurrentTime = `${yy}-${mm}-${dd} 00:00:00`;
  let endCurrentTime = `${yy}-${mm}-${dd} 23:59:59`;

  return { startCurrentTime, endCurrentTime };
  // this.requestChoseDmMsg(); //执行获取断面
}


// 获取当前时间的十位时间戳

export function getCurrentTimeStemp(){
  let now = new Date()
  let timestamp = Math.floor(now.getTime()/1000)

  return timestamp
}

